import request from './axios'
import {DEFAULT_PAGENUM, DEFAULT_PAGESIZE} from "@/constent";

/**
 * 发布资源
 * @param data
 */
export const pushResource = (data) => {
    return request.post('/resource/pushResource', data)
}
/**
 * 获取资源列表
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
const params = {
    pageNum:DEFAULT_PAGENUM,
    pageSize:DEFAULT_PAGESIZE
}
export const getResourceList = (data = params) => {
    return request.post('/resource/getResourceList',data);
}

/**
 * 获取我的资源
 * @param pageSize
 * @returns {Promise<AxiosResponse<any>>}
 */
export const getMyResource = (pageSize = DEFAULT_PAGESIZE, userId) => {
    return request({
        url:'/resource/getMyResource',
        method:'get',
        params:{
            pageSize,
            userId
        }
    });
}

/**
 * 删除我的资源
 * @param resId
 * @returns {Promise<AxiosResponse<any>>}
 */
export const removeRes = (resId) => {
    return request({
        url:'/resource/removeRes',
        method:'get',
        params:{
            resId
        }
    });
}

/**
 * 提交举报
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export const addReport = (data) => {
    return request.post('/report/addReport',data);
}

/**
 * 获取举报列表
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export const reportList = (data) => {
    return request.post('/report/reportList', data);
}

/**
 * 处理举报
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export const handlerReport = (data) => {
    return request.post('/report/handlerReport', data);
}

/**
 * 获取举报详情
 * @param id
 * @returns {Promise<AxiosResponse<any>>}
 */
export const getReportDetail = (id) => {
    return request({
        url:'/report/getReportDetail',
        method:'get',
        params:{
            id
        }
    })
}

/**
 * 获取举报详情
 * @returns {Promise<AxiosResponse<any>>}
 */
export const getMyReport = () => {
    return request({
        url:'/report/getMyReport',
        method:'get'
    })
}


/**
 * 获取资源分类列表
 * @returns {Promise<AxiosResponse<any>>}
 */
export const getTypeList = () => {
    return request({
        url:'/restype/getTypeList',
        method:'get'
    });
}

/**
 * 添加分类
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export const insertOrUpdateResType = (data) => {
    return request.post('/restype/insertOrUpdateResType', data);
}

/**
 * 删除分类
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export const removeType = (resTypeId) => {
    return request({
        url:'/restype/removeType',
        method:'get',
        params:{
            resTypeId
        }
    });
}

/**
 * 获取资源详情页
 * @returns {Promise<AxiosResponse<any>>}
 */
export const getResDetail = (resId) => {
    return request({
        url:'/resource/getResDetail',
        method:'get',
        params:{
            resId
        }
    });
}
